import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)
export default new Vuex.Store({
  state: {
    shoppingTotal:0,
    deskName:'',
    //当前菜单栏索引
    presentIndex:0,
    //点击返回按钮的上一级菜单
    previousMenu:[],

  },
  mutations: {
    updateShoppingTotal(state,total){
      state.shoppingTotal=total;
    },
    autoIncrementShoppingTotal(state){
      state.shoppingTotal++;
    },
    updateDeskName(state,deskName){
      state.deskName=deskName;
    },
    //添加上一级子菜单
    addPreviousMenu(state,menuName){
      state.previousMenu.push(menuName)
    },
    //更新当前菜单索引
    updatePresentIndex(state,index){
      state.presentIndex=index;
    }
  },
  getters:{
    //返回上一级子菜单
    getPreviousMenu(state){
      return state.previousMenu;
    },
    //获取当前菜单索引
    getPresentMenuIndex(state){

      return state.presentIndex;
    }
  },
  actions: {

  },
  modules: {
  }
})
